#pragma once


//-----------------------------------------------------------------------------
//															Rectangle class
//-----------------------------------------------------------------------------
template<typename T>
class CRectangle
{
public:
	CRectangle();
	CRectangle(T _x, T _y, T _width, T _height);

	T left() const;
	T top() const;
	T right() const;
	T bottom() const;

	bool contains(T _x, T _y) const;
	bool empty() const;

public:
	T x;
	T y;
	T width;
	T height;
};

//	typedefs
typedef CRectangle<int>		Rect;
typedef CRectangle<float>	RectF;

//-----------------------------------------------------------------------------
template<typename T>
CRectangle<T>::CRectangle()
: x(0)
, y(0)
, width(0)
, height(0)
{

}

template<typename T>
CRectangle<T>::CRectangle(T _x, T _y, T _width, T _height)
: x(_x)
, y(_y)
, width(_width)
, height(_height)
{

}

template<typename T>
T CRectangle<T>::left() const
{
	return x;
}

template<typename T>
T CRectangle<T>::top() const
{
	return y;
}

template<typename T>
T CRectangle<T>::right() const
{
	return x + width;
}

template<typename T>
T CRectangle<T>::bottom() const
{
	return y + height;
}

template<typename T>
bool CRectangle<T>::contains(T _x, T _y) const
{
	return _x >= left() && _x <= right() && _y >= top() && _y <= bottom();
}

template<typename T>
bool CRectangle<T>::empty() const
{
	return width == 0 && height == 0;
}